<?php
/**
 * Created by PhpStorm.
 * User: 10467
 * Date: 2020/11/7
 * Time: 10:48
 */

namespace app\admin\model\Video;

use app\admin\model\User\UserModel;
use think\facade\Db;
use think\Model;

class VideoUserCommentModel extends Model
{

    /**
     * 数据表名
     * @var string
     */
    protected $name = "video_user_comment";

    public function user()
    {
        return $this->hasOne(UserModel::class, 'id', 'uid')->field('id,nickname');
    }
    public static function dels($where)
    {

        $row = self::where($where)->find();
        if (!$row) return false;

        if($row){
            self::update(['is_del' => 1, 'top' => 0],['id'=> $where['id']]);
            Db::name('video_user')->where('id', $row['video_id'])->dec('nums_discuss')->update();
            return true;
        }
        return false;
    }

}